const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}


var uploadVideo=function( ){
  
    console.log("uploadVideo")

    wx.chooseVideo({
        sourceType: ['album', 'camera'],
        maxDuration: 20,
        camera: 'back',
        success(res) {
            console.log(res)
            var videores = res
            var videoPath = res.tempFilePath
            var videoSeconds = res.duration
            var videoWidth = res.width
            var videoHeight = res.height
            wx.navigateTo({
                url: '../bgm/bgm?videoPath=' + videoPath
                    + "&videoSeconds=" + videoSeconds
                    + "&videoWidth=" + videoWidth
                    + "&videoHeight=" + videoHeight
                ,
            })

        }
    })



 }
module.exports = {
  formatTime: formatTime,
  uploadVideo:uploadVideo
}
